<!--
   Copyright (C) 2021 DuckDuckGo, Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

-->

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>DuckDuckGo Privacy Essentials Debugger</title>
  
  <link rel="stylesheet" href="../public/css/base.css">

  <style type="text/css">
    h1 {
      font-size: 2em;
    }
    .page-container {
      margin: 1em;
    }
    
    .frm__input {
      line-height: inherit;
      width: auto;
    }
    
    #table-filter > label [type="checkbox"] {
      margin: 0 4px;
    }
    
    #table-filter {
      line-height: 2;
    }
    
    details > summary {
      display: inline list-item !important;
    }
  
    .header {
      margin-top: 16px;
    }

    #settings-panel {
      position: sticky;
      top: 0;
      background-color: white;
    }

    #protections {
      padding-top: 0px;
    }

    #protections > button, #table-filter > label {
      border-radius: 4px;
      padding: 2px 4px;
      margin: 2px;
    }

    .protection-button-on {
      background-color: #A0F2A8;
      color: #333;
    }

    .protection-button-on:hover {
      background-color: #ADFFAD;
      color: #333;
    }

    .protection-button-off {
      background-color: #FBBEBF;
      color: #333;
    }

    .protection-button-off:hover {
      background-color: #FFCBCC;
      color: #333;
    }

    .block {
      background-color: #FBBEBF;
      display: revert; /* To avoid clashing with .block in base.css */
    }

    .block[hidden] {
      display: none;
    }

    .redirect {
      background-color: #FDD20A;
    }

    .ignore {
      background-color: #CACACA;
    }

    .cookie-tracker {
      background-color: #9CB8FF
    }

    .set-cookie-tracker {
      background-color: #BDA8FC
    }

    table {
      table-layout: fixed;
      width: 100%;
      border-collapse: collapse;
      border: 1px solid black;
    }

    thead {
      position: sticky;
    }

    thead th:nth-child(1) {
      width: 2%;
    }

    thead th:nth-child(2) {
      width: 48%;
    }

    thead th:nth-child(3) {
      width: 18%;
    }

    thead th:nth-child(4) {
      width: 22%;
    }

    thead th:nth-child(5) {
      width: 10%;
    }

    th,
    td {
      padding: 5px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    /* Make it easier to view contents of currently-hovered cell. */
    td:hover {
      white-space: break-spaces;
      background-color: beige;
      word-wrap: break-word;
    }

    tr:hover {
      border: 1px solid black;
    }

    tr > td:nth-child(4) {
      word-wrap: anywhere;
      overflow: auto;
      white-space: break-spaces;
    }

    #tab-picker {
      width: 300px;
    }
  </style>
</head>

<body>
  <template id="cookie-row">
    <tr>
      <td></td>
      <td></td>
      <td><span class="request-action"></span><span class="action-count"></span></td>
      <td></td>
      <td></td>
    </tr>
  </template>

  <template id="request-row">
    <tr>
      <td><a href="" class="block-toggle">I</a></td>
      <td></td>
      <td><span class="request-action"></span><span class="action-count"></span></td>
      <td></td>
      <td></td>
    </tr>
  </template>

  <div class="page-container">

    <h1>DuckDuckGo Privacy Essentials Debugger</h1>
    
    <div id="settings-panel">
      <div class="header">
        <a href="./list-editor.html" target="_blank">🗒</a>
        <select id="tab-picker">
          <option value="">--Select Tab--</option>
        </select>
        <button id="clear" class="btn">Clear</button>
        <button id="refresh" class="btn">Reload page</button>
        <span>|</span>
        <button id="protection" class="btn">Protection: ??</button>
        <label for="tds">Blocklist: </label>
        <select name="tds" id="tds">
          <option value="live">Live</option>
          <option value="next">Next</option>
          <option value="beta">Beta</option>
        </select>
      </div>
      
      <div class="header" id="protections">
      </div>
      
      <details class="header">
        <summary class="btn">Display/hide options</summary>
        <div id="table-filter" class="header">
          <label class="block">
            <input data-filter-toggle="blocked" type="checkbox" checked><span>Blocked</span>
          </label>
          <label class="ignore">
            <input data-filter-toggle="ignored" type="checkbox" checked><span>Ignored</span>
          </label>
          <label class="ignore">
            <input data-filter-toggle="ignoredFirstParty" type="checkbox" checked><span>Ignored (1P)</span>
          </label>
          <label class="redirect">
            <input data-filter-toggle="redirected" type="checkbox" checked><span>Redirected</span>
          </label>
          <label class="cookie-tracker">
            <input data-filter-toggle="cookieHTTP" type="checkbox" checked><span>HTTP Cookies</span>
          </label>
          <label class="jsException">
            <input data-filter-toggle="jsException" type="checkbox" checked><span>JS Exceptions</span>
          </label>
          <label class="jscookie">
            <input data-filter-toggle="cookieJS" type="checkbox" checked><span>JS Cookies</span>
          </label>
          <label class="runtimeChecks">
            <input data-filter-toggle="runtimeChecks" type="checkbox" checked><span>Runtime Checks</span>
          </label>
          <label class="proxyCalls">
            <input data-filter-toggle="proxyCalls" type="checkbox"><span>Proxy calls</span>
          </label>
          <label class="none">
            <input data-filter-toggle="noneRequest" type="checkbox" checked><span>none</span>
          </label>
          <label class="ignore-user">
            <input data-filter-toggle="ignoreUser" type="checkbox" checked><span>ignore-user</span>
          </label>
          <div>
            <label for="search-box">Filter: </label>
            <input type="text" name="search-box" id="search-box" class="frm__input">
          </div>
        </div>
      </details>
    </div>
    
    <table class="header">
      <thead class="silver-bg">
        <tr>
          <th></th>
          <th>URL</th>
          <th>Action</th>
          <th>Domain</th>
          <th>Type</th>
        </tr>
      </thead>
      <tbody id="request-table"></tbody>
    </table>
  </div>

  <script src="/public/js/devtools-panel.js"></script>
</body>

</html>
